<template>
  <el-dialog title="授权信息" :visible="visible" :close-on-click-modal="false" @close="close">
    <el-form
      ref="form"
      :model="entityData"
      :rules="rules"
      label-width="120px"
      label-position="right"
      style="width:90%;margin:0px auto;"
    >
      <!--表单区域 -->
      <el-form-item label="是否已授权">
        <dictionary-radio-group
          v-model="entityData.validFlag"
          readonly
          :code="constant.DICTIONARY_TYPE_CODES.YES_OR_NO"
        />
      </el-form-item>
      <el-form-item label="无效原因">
        <el-input v-model="entityData.invalidReason" readonly />
      </el-form-item>
      <el-form-item label="申请码" prop="applyCode">
        <el-input v-model="entityData.applyCode" readonly type="textarea" :rows="8" />
      </el-form-item>
      <el-form-item label="授权码" prop="licenceCode">
        <el-input v-model="entityData.licenceCode" type="textarea" :rows="8" />
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="save">保存</el-button>
      <el-button @click="close">关闭</el-button>
    </div>
  </el-dialog>
</template>

<script>
import DictionaryRadioGroup from '@/components/popsoft/DictionarySelect/DictionaryRadioGroup'
export default {
  components: { DictionaryRadioGroup },
  data() {
    return {
      visible: false,

      entityData: {

      },
      rules: {
        licenceCode: [
          { required: true, message: '请输入授权码', trigger: 'blur' }
        ]
      }

    }
  },
  methods: {
    show() {
      this.$api.system.systemManage.getLicenceInfo()
        .then(res => {
          this.entityData = res.data
          this.visible = true
        }
        )
    },
    save() {
      this.$refs.form.validate(valid => {
        if (valid) {
          this.$api.system.systemManage.saveLicenceCode(this.entityData)
            .then(res => {
              this.entityData = res.data
            }
            )
        }
      }
      )
    },
    close() {
      this.visible = false
    }
  }

}

</script>

<style lang="scss">
</style>
